home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / newsgroups / misc.19981211-19990422 / 000344_news@watsun.cc.columbia.edu _Wed Mar 10 20:06:45 1999.msg < prev    next >
Internet Message Format  |  2020-01-01  |  7KB

  1. Return-Path: <news@watsun.cc.columbia.edu>
  2. Received: from newsmaster.cc.columbia.edu (newsmaster.cc.columbia.edu [128.59.59.30])
  3.     by watsun.cc.columbia.edu (8.8.5/8.8.5) with ESMTP id UAA23494
  4.     for <kermit.misc@watsun.cc.columbia.edu>; Wed, 10 Mar 1999 20:06:43 -0500 (EST)
  5. Received: (from news@localhost)
  6.     by newsmaster.cc.columbia.edu (8.8.5/8.8.5) id TAA10102
  7.     for kermit.misc@watsun.cc.columbia.edu; Wed, 10 Mar 1999 19:50:29 -0500 (EST)
  8. X-Authentication-Warning: newsmaster.cc.columbia.edu: news set sender to <news> using -f
  9. From: jwmanly+news@amherst.edu
  10. Subject: C-Kermit Scripting using INPUT and LOG SESSION
  11. Date: 10 Mar 1999 19:42:53 -0500
  12. Organization: Amherst College
  13. Message-ID: <36e7118d.0@amhnt2.amherst.edu>
  14. To: kermit.misc@mailrelay2.cc.columbia.edu
  15.  
  16. Hi there.
  17.  
  18. (This message refers to using C-Kermit 6.0.192 under VMS V7.1)
  19.  
  20. I have some questions about how C-Kermit handles its internal buffers,
  21. because I'm seeing some behavior that suggests it is more complex than I
  22. thought.  In particular, I see in the C-Kermit help that there are separate
  23. CLEAR command for DEVICE and INPUT, and I guess what I could use is some
  24. information on how these two buffers are related -- that is, how does
  25. information get moved from one to the other, and which one does LOG SESSION
  26. read out of?
  27.  
  28. Basically, I'm trying to use C-Kermit to transmit some HTML form data to a
  29. web-server, and extract a portion of the resulting returned web page.  I'm
  30. sending the form data via the TRANSMIT command.  The web page that comes
  31. back looks like this:
  32.  
  33. HTTP/1.1 200 OK
  34. blah blah blah<p>
  35. blah blah blah<p>
  36. <font size="7"...<p>
  37. THE DATA I WANT TO CAPTURE<p>
  38. blah blah blah<p>
  39. blah blah blah<p>
  40. </html>
  41.  
  42. What I want is to capture the "THE DATA I WANT TO CAPTURE<p>" piece in an 
  43. external file for further processing outside of Kermit.  I thought this
  44. would be pretty easy: Just connect to the server, transmit the form data to
  45. it, do an INPUT for the |<font size="7"| string, another INPUT to advance
  46. to the following |<p>| string, turn on session logging, do another INPUT
  47. for the |<p>| string, turn off logging, hangup and exit.
  48.  
  49. Well, needless to say it hasn't been this straightforward, and the results
  50. don't even seem to be consistent. It is as if the LOG SESSION command is
  51. working out of a buffer that is somehow different (or not synchronized)
  52. with the one the INPUT command is using.  My actual script is down below,
  53. but before we get to that, I've stumbled over some other strangeness as
  54. I've tried to debug this issue, so let's go over those first.
  55.  
  56. Consider the following script:
  57. ---------------------------------------------------------------------------
  58. set host www.qrz.com:80
  59. set input echo off
  60. set transmit echo off
  61. set transmit prompt 0
  62. clear
  63. transmit form.txt
  64. log session form.out
  65. pause 10
  66. log session
  67. hangup
  68. exit
  69. ---------------------------------------------------------------------------
  70.  
  71. This seems about as simple as it gets: transmit the form data, start
  72. logging the session, wait 10 seconds for everything to come through, exit.
  73. This should record everything that comes back.  But it doesn't.  In fact,
  74. it doesn't record anything.  BUT, if I replace that "PAUSE 10" command with
  75. an "INPUT 10 XXXXXXX" string, THEN it works.  
  76.  
  77. Why is this?  Why the necessity for the INPUT line? I assume it is to force
  78. C-Kermit to somehow "consume" or "process" the information, but is there
  79. any other, cleaner way to do that?  (And is this the process of moving
  80. information between the aformentioned DEVICE and INPUT buffers?)
  81.  
  82. OK, on to my real problem.  Consider the script below, the one to solve the
  83. problem I describe at the start of my message:
  84.  
  85. ---------------------------------------------------------------------------
  86. set host www.qrz.com:80
  87. set input echo off
  88. set transmit echo off
  89. set transmit prompt 0
  90. clear
  91. transmit form.txt
  92. input 10 <font size="7"
  93. input 10 <p>
  94. log session form.out
  95. input 10 <p>
  96. log session
  97. input 10 </html>
  98. hangup
  99. exit
  100. ---------------------------------------------------------------------------
  101.  
  102. This doesn't work reliably, though it does work sometimes.  If I run this
  103. script six times, sometimes I get the data I want in the FORM.OUT
  104. file, and the other two times I get nothing.  I've tried putting debugging
  105. statements in (to see, for example, whether the "INPUT 10 <p>" command is
  106. failing, and sometimes it is), but they haven't helped me figure out what
  107. is going on here.  I'm fairly confident that the remote side is returning
  108. the same information each time, so I'm thinking the problem has to do with
  109. the timing of exactly WHEN information from the remote side arrives. 
  110. Should those subsequent INPUT command actually be REINPUT commands?  What
  111. happens if I have the following commands in a script:
  112.  
  113.   INPUT 10 AAA
  114.   PAUSE 1
  115.   INPUT 10 BBB
  116.  
  117. and the string "BBB" comes in during the first 10 seconds.  Will
  118. that second INPUT command succeed or fail?  
  119.  
  120. Final question: notice how I put that "INPUT 10 </html>" command at the end
  121. of the script to flush out whatever other data comes back from the remote
  122. server following the part that I am intersted in?  If I don't do this, when
  123. I hit the EXIT at the end of the script (even though it follows the HANGUP
  124. command), I get the "There may still be a connection open, OK to exit?"
  125. message when the script finishes.  I assume this is because there is
  126. "unconsumed" data in the buffer.  How do I tell Kermit to drop the
  127. connection regardless of whether there is anything left in the buffer or
  128. not, even if data is still streaming in?
  129.  
  130. BTW, the FORM.TXT file that I'm transmitting to the remote server looks
  131. like this:
  132. ---------------------------------------------------------------------------
  133. POST /wrad/directory.cgi HTTP/1.0
  134. Referer: http://www.qrz.com/
  135. Connection: Keep-Alive
  136. User-Agent: Mozilla/3.0 (Macintosh; I; PPC)
  137. Host: www.qrz.com
  138. Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, *.*
  139. Content-type: application/x-www-form-urlencoded
  140. Content-length: 14
  141.  
  142. callsign=k1nor
  143. ---------------------------------------------------------------------------
  144.  
  145. I know I'm asking kind of complicated questions, and I'm having some
  146. trouble making them as straightforward as possible, but though I've been
  147. scripting Kermit for years and years, the buffer operations and
  148. interactions between the INPUT, REINPUT, CLEAR DEVICE, and CLEAR INPUT
  149. commands continues to mess me up.  If someone could give me a quick rundown
  150. on how these things interact with each other and with the LOG SESSION
  151. command, I would be most grateful.  That alone might be enough to let me
  152. solve my own problems with the above scripts.
  153.  
  154. - John W. Manly  <jwmanly@amherst.edu>
  155.